<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      width: 200px;
      height: 200px;
      background-color: skyblue;
    }

    p {
      position: absolute;
      top: 75px;
      left: 55px;
    }
  </style>
</head>

<body>
  <div>
    <p></p>
  </div>
  <script>
    /* click 鼠标点击
    mouseenter  鼠标经过
    mouseleave  鼠标离开 */

    const div = document.querySelector('div')
    const p = document.querySelector('p')
    // 鼠标经过
    div.addEventListener('mouseenter', function () {
      console.log(`轻轻的我来了`)
      p.innerHTML = `轻轻的我来了`
    })
    // 鼠标离开
    div.addEventListener('mouseleave', function () {
      console.log(`轻轻的我走了`)
      p.innerHTML = `轻轻的我走了`
    })
  </script>
</body>

</html>